/**
 * 功能描述
 */
define(function (require, exports, module) {
    //引入视图基类
    var ELView = require("elview");
    var HandlerBars = require("handlebars");
    
    //assets
    var template = require("./assets/tpl/roomstatewhole_main.tpl");
    require("./assets/css/roomstatewhole_main.css");
    var typeTpl = require("./assets/tpl/roomstatewhole_type.tpl");
    
    //business

    //component
    var roomStateWholeSubnav = require("./component/roomStateWholeSubnav");
    var roomStateWholeGrid = require("./component/roomStateWholeGrid");
    var roomStateWholeform = require("./component/roomStateWholeform");    
    //constant

    //handler
    var event = require("./handler/roomStateWholeEvents");
    //store
    var store = require("./store/processData");
    var App = ELView.extend({
        attrs: {
            template: template
        },
        store:store,        
        setData:event.setData,
        renderRoomNumber:event.renderRoomNumber,
        appointSumEvent:event.appointSumEvent,
        events:{        	
    		"click .room-select":function(e){
    			event.clickRoom(e,this);    			
    		},
    		"click .room-type":function(e){
    			var state = $(e.currentTarget).attr("data-state");
    			this.setData(state,this);
    		}
    	},
        initComponent: function (params, widget) {
        	roomStateWholeSubnav.initComponent(params, widget);
        	roomStateWholeGrid.initComponent(params, widget);
        	roomStateWholeform.initComponent(params, widget);
        	
        	var html = HandlerBars.compile(typeTpl)();
        	$(".J-status").html(html);
        	this.setData("",widget);
        },
        toCard:function(){
        	this.get("subnav").show(["toDetail","appointSum","print"]).hide(["return","scattercheckin","checkin",
        	                                            "nonmemcheckout","checkoutsettlement"]);
			this.hide([".J-grid",".J-form",".J-appointRoom"]).show([".J-status",".J-room"]);			
			this.get("form").reset();
        },
        toBar:function(){
        	this.get("subnav").show(["return"]).hide(["toDetail","appointSum","print","scattercheckin",
        	                                          "checkin","nonmemcheckout","checkoutsettlement"]);
 			this.show([".J-appointRoom"]).hide([".J-grid",".J-form",".J-status",".J-room"]);		
        },
        afterInitComponent: function (params, widget) {
        	
        }
    });

    module.exports = App;
});
